﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Infrastructuse
{
    /// <summary>
    /// SqlSugar 帮助类
    /// </summary>
    public class SqlSugarDbHelp
    {
        public SqlSugarClient Db { get; set; }

        public SqlSugarDbHelp()
        {
            Db = new SqlSugarClient(new ConnectionConfig()
            {
                ConnectionString = "server=localhost;database=WMSDataBase;uid=root;pwd=123456",
                DbType = DbType.MySql,
                IsAutoCloseConnection = true
            });

            //自动创建数据库（如已存在会自动跳过）
            Db.DbMaintenance.CreateDatabase("WMSDataBase");

            Db.Aop.OnLogExecuting = (sql, pars) =>
            {
                Console.WriteLine($"SQL: {sql}");
            };
        }
    }
}
